import React, { Component } from 'react';
// import img from '../../assets/cos.png'
import {user_goods} from '../../utils/api'
import {withRouter} from "react-router-dom"
class MyList extends Component {
    //定义组件状态
    constructor (props){
        super(props);
        this.state={
            goodlist:[],
            id:281462
        }
    }
    
    componentDidMount(){
            user_goods({id:this.props.history.location.search.slice(4)}).then((res)=>{
                
                if(res.data.code===200){
                    this.setState({
                        goodlist:res.data.list
                    })
                }
               
            })

        }
    hehe(id){
        
        this.props.history.push('/detail/'+id)
    }
    render() {
        return (
            <div className='Mylist'>
                <div className='Mylist_top'>
                    <span>综合</span>
                    <span>销量</span>
                    <span>新品</span>
                    <span>价格</span>
                    <span>筛选</span>
                </div>
                <div className='Mylist_content'>
                    {
                        this.state.goodlist.map((item,index)=>{
                            return (
                                <div className='Mylist_content_one' key={index} onClick={ ()=>{this.hehe(item.id)} }>
                                    <img src={item.pic} alt="" />
                                    <p className='p1'>{item.name}</p>
                                    <p className='p2'>原价¥<span>{item.salesPrice.value}</span></p>
                                    <p className='p3'>{item.salesPrice.name}¥<span>{item.salesPrice.value}</span></p>
                                </div>
                            )
                        })
                        
                    }
                    
                </div>
            </div>
        );
    }
}

export default withRouter(MyList);